<template>
  <div class="login">
    登录<br />
    <el-form :model="loginForm"  label-width="80px" class="demo-loginForm">
      <el-form-item label="账号" prop="userName" >
        <el-input v-model="loginForm.userName"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input type="password" v-model="loginForm.passWord" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submitForm('loginForm')">登录</el-button>
        <el-button @click="resetForm('loginForm')">取消</el-button>
      </el-form-item>
    </el-form>

  </div>
</template>
<script>
export default {
  data() {
    return {
      loginForm: {
        userName: '',
        passWord: ''
      }

    }
  },
  methods: {
    submitForm() {
      console.log("登录");
      this.$axios.get("http://localhost:8080/login", {
        params: { userName: this.loginForm.userName, passWord: this.loginForm.passWord }
      }).then(resp => {
        if (resp.data.code == 200) {
          this.$router.push("/studentList");
        } else {
          this.$message("账号或密码错误");
        }
      })
    },
    resetForm() {

    }
  }
}
</script>
<style>
.demo-loginForm {
  width: 500;
  margin: 0px auto;
  padding-top: 100px;
}
.login{
  .home {
      height: 100%;
      width: 100%;
      background-image: url('../assets/logo.png');
      /* background-size: cover; */
    }
}
</style>